(function() {
    var r, t = [].indexOf || function(n) {
            for (var t = 0, i = this.length; i > t; t++)
                if (t in this && this[t] === n) return t;
            return -1
        },
        u = [].slice,
        i = function(n, t) {
            return function() {
                return n.apply(t, arguments)
            }
        },
        n = {}.hasOwnProperty;
    (r = function(n) {
        return "object" == typeof exports && "object" == typeof module ? n(require("jquery")) : "function" == typeof define && define.amd ? define(["jquery"], n) : n(jQuery)
    })(function(r) {
        var v, nt, f, b, tt, it, y, o, rt, s, p, c, w, k, d, g, ut, e, l, h, a;
        return nt = function(n, t, i) {
            var f, u, r, e;
            for (n += "", u = n.split("."), r = u[0], e = u.length > 1 ? i + u[1] : "", f = /(\d+)(\d{3})/; f.test(r);) r = r.replace(f, "$1" + t + "$2");
            return r + e
        }, p = function(n) {
            var t;
            return t = {
                    digitsAfterDecimal: 2,
                    scaler: 1,
                    thousandsSep: ",",
                    decimalSep: ".",
                    prefix: "",
                    suffix: ""
                }, n = r.extend({}, t, n),
                function(t) {
                    var i;
                    return isNaN(t) || !isFinite(t) ? "" : (i = nt((n.scaler * t).toFixed(n.digitsAfterDecimal), n.thousandsSep, n.decimalSep), "" + n.prefix + i + n.suffix)
                }
        }, e = p(), l = p({
            digitsAfterDecimal: 0
        }), h = p({
            digitsAfterDecimal: 1,
            scaler: 100,
            suffix: "%"
        }), f = {
            count: function(n) {
                return null == n && (n = l),
                    function() {
                        return function() {
                            return {
                                count: 0,
                                push: function() {
                                    return this.count++
                                },
                                value: function() {
                                    return this.count
                                },
                                format: n
                            }
                        }
                    }
            },
            uniques: function(n, i) {
                return null == i && (i = l),
                    function(r) {
                        var u;
                        return u = r[0],
                            function() {
                                return {
                                    uniq: [],
                                    push: function(n) {
                                        var i;
                                        return i = n[u], t.call(this.uniq, i) < 0 ? this.uniq.push(n[u]) : void 0
                                    },
                                    value: function() {
                                        return n(this.uniq)
                                    },
                                    format: i,
                                    numInputs: null != u ? 0 : 1
                                }
                            }
                    }
            },
            sum: function(n) {
                return null == n && (n = e),
                    function(t) {
                        var i;
                        return i = t[0],
                            function() {
                                return {
                                    sum: 0,
                                    push: function(n) {
                                        if (!isNaN(parseFloat(n[i]))) return this.sum += parseFloat(n[i])
                                    },
                                    value: function() {
                                        return this.sum
                                    },
                                    format: n,
                                    numInputs: null != i ? 0 : 1
                                }
                            }
                    }
            },
            extremes: function(n, t) {
                return null == t && (t = e),
                    function(i) {
                        var r;
                        return r = i[0],
                            function(i) {
                                return {
                                    val: null,
                                    sorter: y(null != i ? i.sorters : void 0, r),
                                    push: function(t) {
                                        var u, f, e, i;
                                        return i = t[r], ("min" === n || "max" === n) && (i = parseFloat(i), isNaN(i) || (this.val = Math[n](i, null != (u = this.val) ? u : i))), "first" === n && this.sorter(i, null != (f = this.val) ? f : i) <= 0 && (this.val = i), "last" === n && this.sorter(i, null != (e = this.val) ? e : i) >= 0 ? this.val = i : void 0
                                    },
                                    value: function() {
                                        return this.val
                                    },
                                    format: function(n) {
                                        return isNaN(n) ? n : t(n)
                                    },
                                    numInputs: null != r ? 0 : 1
                                }
                            }
                    }
            },
            quantile: function(n, t) {
                return null == t && (t = e),
                    function(i) {
                        var r;
                        return r = i[0],
                            function() {
                                return {
                                    vals: [],
                                    push: function(n) {
                                        var t;
                                        return t = parseFloat(n[r]), isNaN(t) ? void 0 : this.vals.push(t)
                                    },
                                    value: function() {
                                        var t;
                                        return 0 === this.vals.length ? null : (this.vals.sort(function(n, t) {
                                            return n - t
                                        }), t = (this.vals.length - 1) * n, (this.vals[Math.floor(t)] + this.vals[Math.ceil(t)]) / 2)
                                    },
                                    format: t,
                                    numInputs: null != r ? 0 : 1
                                }
                            }
                    }
            },
            runningStat: function(n, t, i) {
                return null == n && (n = "mean"), null == t && (t = 1), null == i && (i = e),
                    function(r) {
                        var u;
                        return u = r[0],
                            function() {
                                return {
                                    n: 0,
                                    m: 0,
                                    s: 0,
                                    push: function(n) {
                                        var i, t;
                                        return t = parseFloat(n[u]), isNaN(t) ? void 0 : (this.n += 1, 1 === this.n ? this.m = t : (i = this.m + (t - this.m) / this.n, this.s = this.s + (t - this.m) * (t - i), this.m = i))
                                    },
                                    value: function() {
                                        if ("mean" === n) return 0 === this.n ? NaN : this.m;
                                        if (this.n <= t) return 0;
                                        switch (n) {
                                            case "var":
                                                return this.s / (this.n - t);
                                            case "stdev":
                                                return Math.sqrt(this.s / (this.n - t))
                                        }
                                    },
                                    format: i,
                                    numInputs: null != u ? 0 : 1
                                }
                            }
                    }
            },
            sumOverSum: function(n) {
                return null == n && (n = e),
                    function(t) {
                        var i, r;
                        return r = t[0], i = t[1],
                            function() {
                                return {
                                    sumNum: 0,
                                    sumDenom: 0,
                                    push: function(n) {
                                        return isNaN(parseFloat(n[r])) || (this.sumNum += parseFloat(n[r])), isNaN(parseFloat(n[i])) ? void 0 : this.sumDenom += parseFloat(n[i])
                                    },
                                    value: function() {
                                        return this.sumNum / this.sumDenom
                                    },
                                    format: n,
                                    numInputs: null != r && null != i ? 0 : 2
                                }
                            }
                    }
            },
            sumOverSumBound80: function(n, t) {
                return null == n && (n = !0), null == t && (t = e),
                    function(i) {
                        var r, u;
                        return u = i[0], r = i[1],
                            function() {
                                return {
                                    sumNum: 0,
                                    sumDenom: 0,
                                    push: function(n) {
                                        return isNaN(parseFloat(n[u])) || (this.sumNum += parseFloat(n[u])), isNaN(parseFloat(n[r])) ? void 0 : this.sumDenom += parseFloat(n[r])
                                    },
                                    value: function() {
                                        var t;
                                        return t = n ? 1 : -1, (.821187207574908 / this.sumDenom + this.sumNum / this.sumDenom + 1.2815515655446004 * t * Math.sqrt(.410593603787454 / (this.sumDenom * this.sumDenom) + this.sumNum * (1 - this.sumNum / this.sumDenom) / (this.sumDenom * this.sumDenom))) / (1 + 1.6423744151498161 / this.sumDenom)
                                    },
                                    format: t,
                                    numInputs: null != u && null != r ? 0 : 2
                                }
                            }
                    }
            },
            fractionOf: function(n, t, i) {
                return null == t && (t = "total"), null == i && (i = h),
                    function() {
                        var r;
                        return r = 1 <= arguments.length ? u.call(arguments, 0) : [],
                            function(u, f, e) {
                                return {
                                    selector: {
                                        total: [
                                            [],
                                            []
                                        ],
                                        row: [f, []],
                                        col: [
                                            [], e
                                        ]
                                    }[t],
                                    inner: n.apply(null, r)(u, f, e),
                                    push: function(n) {
                                        return this.inner.push(n)
                                    },
                                    format: i,
                                    value: function() {
                                        return this.inner.value() / u.getAggregator.apply(u, this.selector).inner.value()
                                    },
                                    numInputs: n.apply(null, r)().numInputs
                                }
                            }
                    }
            }
        }, f.countUnique = function(n) {
            return f.uniques(function(n) {
                return n.length
            }, n)
        }, f.listUnique = function(n) {
            return f.uniques(function(t) {
                return t.join(n)
            }, function(n) {
                return n
            })
        }, f.max = function(n) {
            return f.extremes("max", n)
        }, f.min = function(n) {
            return f.extremes("min", n)
        }, f.first = function(n) {
            return f.extremes("first", n)
        }, f.last = function(n) {
            return f.extremes("last", n)
        }, f.median = function(n) {
            return f.quantile(.5, n)
        }, f.average = function(n) {
            return f.runningStat("mean", 1, n)
        }, f["var"] = function(n, t) {
            return f.runningStat("var", n, t)
        }, f.stdev = function(n, t) {
            return f.runningStat("stdev", n, t)
        }, b = function(n) {
            return {
                Count: n.count(l),
                "Count Unique Values": n.countUnique(l),
                "List Unique Values": n.listUnique(", "),
                Sum: n.sum(e),
                "Integer Sum": n.sum(l),
                Average: n.average(e),
                Median: n.median(e),
                "Sample Variance": n["var"](1, e),
                "Sample Standard Deviation": n.stdev(1, e),
                Minimum: n.min(e),
                Maximum: n.max(e),
                First: n.first(e),
                Last: n.last(e),
                "Sum over Sum": n.sumOverSum(e),
                "80% Upper Bound": n.sumOverSumBound80(!0, e),
                "80% Lower Bound": n.sumOverSumBound80(!1, e),
                "Sum as Fraction of Total": n.fractionOf(n.sum(), "total", h),
                "Sum as Fraction of Rows": n.fractionOf(n.sum(), "row", h),
                "Sum as Fraction of Columns": n.fractionOf(n.sum(), "col", h),
                "Count as Fraction of Total": n.fractionOf(n.count(), "total", h),
                "Count as Fraction of Rows": n.fractionOf(n.count(), "row", h),
                "Count as Fraction of Columns": n.fractionOf(n.count(), "col", h)
            }
        }(f), k = {
            Table: function(n, t) {
                return c(n, t)
            },
            "Table Barchart": function(n, t) {
                return r(c(n, t)).barchart()
            },
            Heatmap: function(n, t) {
                return r(c(n, t)).heatmap("heatmap", t)
            },
            "Row Heatmap": function(n, t) {
                return r(c(n, t)).heatmap("rowheatmap", t)
            },
            "Col Heatmap": function(n, t) {
                return r(c(n, t)).heatmap("colheatmap", t)
            }
        }, o = {
            en: {
                aggregators: b,
                renderers: k,
                localeStrings: {
                    renderError: "An error occurred rendering the PivotTable results.",
                    computeError: "An error occurred computing the PivotTable results.",
                    uiRenderError: "An error occurred rendering the PivotTable UI.",
                    selectAll: "Select All",
                    selectNone: "Select None",
                    tooMany: "(too many to list)",
                    filterResults: "Filter values",
                    apply: "Apply",
                    cancel: "Cancel",
                    totals: "Totals",
                    vs: "vs",
                    by: "by"
                }
            }
        }, rt = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], tt = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], a = function(n) {
            return ("0" + n).substr(-2, 2)
        }, it = {
            bin: function(n, t) {
                return function(i) {
                    return i[n] - i[n] % t
                }
            },
            dateFormat: function(n, t, i, r, u) {
                var f;
                return null == i && (i = !1), null == r && (r = rt), null == u && (u = tt), f = i ? "UTC" : "",
                    function(i) {
                        var e;
                        return e = new Date(Date.parse(i[n])), isNaN(e) ? "" : t.replace(/%(.)/g, function(n, t) {
                            switch (t) {
                                case "y":
                                    return e["get" + f + "FullYear"]();
                                case "m":
                                    return a(e["get" + f + "Month"]() + 1);
                                case "n":
                                    return r[e["get" + f + "Month"]()];
                                case "d":
                                    return a(e["get" + f + "Date"]());
                                case "w":
                                    return u[e["get" + f + "Day"]()];
                                case "x":
                                    return e["get" + f + "Day"]();
                                case "H":
                                    return a(e["get" + f + "Hours"]());
                                case "M":
                                    return a(e["get" + f + "Minutes"]());
                                case "S":
                                    return a(e["get" + f + "Seconds"]());
                                default:
                                    return "%" + t
                            }
                        })
                    }
            }
        }, d = /(\d+)|(\D+)/g, w = /\d/, g = /^0/, s = function() {
            return function(n, t) {
                var i, u, r, f, e, o;
                if (null != t && null == n) return -1;
                if (null != n && null == t) return 1;
                if ("number" == typeof n && isNaN(n)) return -1;
                if ("number" == typeof t && isNaN(t)) return 1;
                if (e = +n, o = +t, o > e) return -1;
                if (e > o) return 1;
                if ("number" == typeof n && "number" != typeof t) return -1;
                if ("number" == typeof t && "number" != typeof n) return 1;
                if ("number" == typeof n && "number" == typeof t) return 0;
                if (isNaN(o) && !isNaN(e)) return -1;
                if (isNaN(e) && !isNaN(o)) return 1;
                if (i = String(n), r = String(t), i === r) return 0;
                if (!w.test(i) || !w.test(r)) return i > r ? 1 : -1;
                for (i = i.match(d), r = r.match(d); i.length && r.length;)
                    if (u = i.shift(), f = r.shift(), u !== f) return w.test(u) && w.test(f) ? u.replace(g, ".0") - f.replace(g, ".0") : u > f ? 1 : -1;
                return i.length - r.length
            }
        }(this), ut = function(n) {
            var r, t, i, u;
            i = {};
            t = {};
            for (r in n) u = n[r], i[u] = r, "string" == typeof u && (t[u.toLowerCase()] = r);
            return function(n, r) {
                return null != i[n] && null != i[r] ? i[n] - i[r] : null != i[n] ? -1 : null != i[r] ? 1 : null != t[n] && null != t[r] ? t[n] - t[r] : null != t[n] ? -1 : null != t[r] ? 1 : s(n, r)
            }
        }, y = function(n, t) {
            var i;
            if (null != n)
                if (r.isFunction(n)) {
                    if (i = n(t), r.isFunction(i)) return i
                } else if (null != n[t]) return n[t];
            return s
        }, v = function() {
            function t(n, r) {
                var u, e, o, s, h, c, l, a, v, y;
                null == r && (r = {});
                this.getAggregator = i(this.getAggregator, this);
                this.getRowKeys = i(this.getRowKeys, this);
                this.getColKeys = i(this.getColKeys, this);
                this.sortKeys = i(this.sortKeys, this);
                this.arrSort = i(this.arrSort, this);
                this.input = n;
                this.aggregator = null != (u = r.aggregator) ? u : f.count()();
                this.aggregatorName = null != (e = r.aggregatorName) ? e : "Count";
                this.colAttrs = null != (o = r.cols) ? o : [];
                this.rowAttrs = null != (s = r.rows) ? s : [];
                this.valAttrs = null != (h = r.vals) ? h : [];
                this.sorters = null != (c = r.sorters) ? c : {};
                this.rowOrder = null != (l = r.rowOrder) ? l : "key_a_to_z";
                this.colOrder = null != (a = r.colOrder) ? a : "key_a_to_z";
                this.derivedAttributes = null != (v = r.derivedAttributes) ? v : {};
                this.filter = null != (y = r.filter) ? y : function() {
                    return !0
                };
                this.tree = {};
                this.rowKeys = [];
                this.colKeys = [];
                this.rowTotals = {};
                this.colTotals = {};
                this.allTotal = this.aggregator(this, [], []);
                this.sorted = !1;
                t.forEachRecord(this.input, this.derivedAttributes, function(n) {
                    return function(t) {
                        if (n.filter(t)) return n.processRecord(t)
                    }
                }(this))
            }
            return t.forEachRecord = function(t, i, u) {
                var e, y, o, s, p, h, w, f, c, l, a, v;
                if (e = r.isEmptyObject(i) ? u : function(n) {
                        var t, r, f;
                        for (t in i) f = i[t], n[t] = null != (r = f(n)) ? r : n[t];
                        return u(n)
                    }, r.isFunction(t)) return t(e);
                if (r.isArray(t)) {
                    if (r.isArray(t[0])) {
                        l = [];
                        for (o in t)
                            if (n.call(t, o) && (y = t[o], o > 0)) {
                                f = {};
                                c = t[0];
                                for (s in c) n.call(c, s) && (p = c[s], f[p] = y[s]);
                                l.push(e(f))
                            }
                        return l
                    }
                    for (a = [], h = 0, w = t.length; w > h; h++) f = t[h], a.push(e(f));
                    return a
                }
                if (t instanceof jQuery) return v = [], r("thead > tr > th", t).each(function() {
                    return v.push(r(this).text())
                }), r("tbody > tr", t).each(function() {
                    return f = {}, r("td", this).each(function(n) {
                        return f[v[n]] = r(this).text()
                    }), e(f)
                });
                throw new Error("unknown input format");
            }, t.prototype.forEachMatchingRecord = function(n, i) {
                return t.forEachRecord(this.input, this.derivedAttributes, function(t) {
                    return function(r) {
                        var u, f, e;
                        if (t.filter(r)) {
                            for (u in n)
                                if (e = n[u], e !== (null != (f = r[u]) ? f : "null")) return;
                            return i(r)
                        }
                    }
                }(this))
            }, t.prototype.arrSort = function(t) {
                var r, i;
                return i = function() {
                        var n, u, i;
                        for (i = [], n = 0, u = t.length; u > n; n++) r = t[n], i.push(y(this.sorters, r));
                        return i
                    }.call(this),
                    function(t, r) {
                        var f, u, e;
                        for (u in i)
                            if (n.call(i, u) && (e = i[u], f = e(t[u], r[u]), 0 !== f)) return f;
                        return 0
                    }
            }, t.prototype.sortKeys = function() {
                var n;
                if (!this.sorted) {
                    switch (this.sorted = !0, n = function(n) {
                        return function(t, i) {
                            return n.getAggregator(t, i).value()
                        }
                    }(this), this.rowOrder) {
                        case "value_a_to_z":
                            this.rowKeys.sort(function() {
                                return function(t, i) {
                                    return s(n(t, []), n(i, []))
                                }
                            }(this));
                            break;
                        case "value_z_to_a":
                            this.rowKeys.sort(function() {
                                return function(t, i) {
                                    return -s(n(t, []), n(i, []))
                                }
                            }(this));
                            break;
                        default:
                            this.rowKeys.sort(this.arrSort(this.rowAttrs))
                    }
                    switch (this.colOrder) {
                        case "value_a_to_z":
                            return this.colKeys.sort(function() {
                                return function(t, i) {
                                    return s(n([], t), n([], i))
                                }
                            }(this));
                        case "value_z_to_a":
                            return this.colKeys.sort(function() {
                                return function(t, i) {
                                    return -s(n([], t), n([], i))
                                }
                            }(this));
                        default:
                            return this.colKeys.sort(this.arrSort(this.colAttrs))
                    }
                }
            }, t.prototype.getColKeys = function() {
                return this.sortKeys(), this.colKeys
            }, t.prototype.getRowKeys = function() {
                return this.sortKeys(), this.rowKeys
            }, t.prototype.processRecord = function(n) {
                var i, u, t, f, c, l, e, s, a, h, v, r, o;
                for (i = [], r = [], s = this.colAttrs, f = 0, c = s.length; c > f; f++) o = s[f], i.push(null != (a = n[o]) ? a : "null");
                for (h = this.rowAttrs, e = 0, l = h.length; l > e; e++) o = h[e], r.push(null != (v = n[o]) ? v : "null");
                return t = r.join(String.fromCharCode(0)), u = i.join(String.fromCharCode(0)), this.allTotal.push(n), 0 !== r.length && (this.rowTotals[t] || (this.rowKeys.push(r), this.rowTotals[t] = this.aggregator(this, r, [])), this.rowTotals[t].push(n)), 0 !== i.length && (this.colTotals[u] || (this.colKeys.push(i), this.colTotals[u] = this.aggregator(this, [], i)), this.colTotals[u].push(n)), 0 !== i.length && 0 !== r.length ? (this.tree[t] || (this.tree[t] = {}), this.tree[t][u] || (this.tree[t][u] = this.aggregator(this, r, i)), this.tree[t][u].push(n)) : void 0
            }, t.prototype.getAggregator = function(n, t) {
                var i, r, u;
                return u = n.join(String.fromCharCode(0)), r = t.join(String.fromCharCode(0)), i = 0 === n.length && 0 === t.length ? this.allTotal : 0 === n.length ? this.colTotals[r] : 0 === t.length ? this.rowTotals[u] : this.tree[u][r], null != i ? i : {
                    value: function() {
                        return null
                    },
                    format: function() {
                        return ""
                    }
                }
            }, t
        }(), r.pivotUtilities = {
            aggregatorTemplates: f,
            aggregators: b,
            renderers: k,
            derivers: it,
            locales: o,
            naturalSort: s,
            numberFormat: p,
            sortAs: ut,
            PivotData: v
        }, c = function(t, i) {
            var tt, rt, l, p, a, ut, v, h, e, ft, b, c, w, k, it, g, f, u, nt, y, o, et, s, d;
            ut = {
                table: {
                    clickCallback: null
                },
                localeStrings: {
                    totals: "Totals"
                }
            };
            i = r.extend(!0, {}, ut, i);
            l = t.colAttrs;
            c = t.rowAttrs;
            k = t.getRowKeys();
            a = t.getColKeys();
            i.table.clickCallback && (v = function(r, u, f) {
                var o, s, e;
                s = {};
                for (e in l) n.call(l, e) && (o = l[e], null != f[e] && (s[o] = f[e]));
                for (e in c) n.call(c, e) && (o = c[e], null != u[e] && (s[o] = u[e]));
                return function(n) {
                    return i.table.clickCallback(n, r, s, t)
                }
            });
            b = document.createElement("table");
            b.className = "pvtTable";
            it = function(n, t, i) {
                var u, f, e, h, o, s, c, r;
                if (0 !== t) {
                    for (h = !0, r = u = 0, o = i; o >= 0 ? o >= u : u >= o; r = o >= 0 ? ++u : --u) n[t - 1][r] !== n[t][r] && (h = !1);
                    if (h) return -1
                }
                for (f = 0; t + f < n.length;) {
                    for (c = !1, r = e = 0, s = i; s >= 0 ? s >= e : e >= s; r = s >= 0 ? ++e : --e) n[t][r] !== n[t + f][r] && (c = !0);
                    if (c) break;
                    f++
                }
                return f
            };
            nt = document.createElement("thead");
            for (e in l)
                if (n.call(l, e) && !isNaN(e)) {
                    rt = l[e];
                    o = document.createElement("tr");
                    0 === parseInt(e) && 0 !== c.length && (u = document.createElement("th"), u.setAttribute("colspan", c.length), u.setAttribute("rowspan", l.length), o.appendChild(u));
                    u = document.createElement("th");
                    u.className = "pvtAxisLabel";
                    u.textContent = rt;
                    o.appendChild(u);
                    for (h in a) n.call(a, h) && (p = a[h], d = it(a, parseInt(h), parseInt(e)), -1 !== d && (u = document.createElement("th"), u.className = "pvtColLabel", u.textContent = p[e], u.setAttribute("colspan", d), parseInt(e) === l.length - 1 && 0 !== c.length && u.setAttribute("rowspan", 2), o.appendChild(u)));
                    0 === parseInt(e) && (u = document.createElement("th"), u.className = "pvtTotalLabel pvtRowTotalLabel", u.innerHTML = i.localeStrings.totals, u.setAttribute("rowspan", l.length + (0 === c.length ? 0 : 1)), o.appendChild(u));
                    nt.appendChild(o)
                }
            if (0 !== c.length) {
                o = document.createElement("tr");
                for (h in c) n.call(c, h) && !isNaN(h) && (ft = c[h], u = document.createElement("th"), u.className = "pvtAxisLabel", u.textContent = ft, o.appendChild(u));
                u = document.createElement("th");
                0 === l.length && (u.className = "pvtTotalLabel pvtRowTotalLabel", u.innerHTML = i.localeStrings.totals);
                o.appendChild(u);
                nt.appendChild(o)
            }
            b.appendChild(nt);
            g = document.createElement("tbody");
            for (h in k)
                if (n.call(k, h)) {
                    w = k[h];
                    o = document.createElement("tr");
                    for (e in w) n.call(w, e) && (et = w[e], d = it(k, parseInt(h), parseInt(e)), -1 !== d && (u = document.createElement("th"), u.className = "pvtRowLabel", u.textContent = et, u.setAttribute("rowspan", d), parseInt(e) === c.length - 1 && 0 !== l.length && u.setAttribute("colspan", 2), o.appendChild(u)));
                    for (e in a) n.call(a, e) && (p = a[e], tt = t.getAggregator(w, p), s = tt.value(), f = document.createElement("td"), f.className = "pvtVal row" + h + " col" + e, f.textContent = tt.format(s), f.setAttribute("data-value", s), null != v && (f.onclick = v(s, w, p)), o.appendChild(f));
                    y = t.getAggregator(w, []);
                    s = y.value();
                    f = document.createElement("td");
                    f.className = "pvtTotal rowTotal";
                    f.textContent = y.format(s);
                    f.setAttribute("data-value", s);
                    null != v && (f.onclick = v(s, w, []));
                    f.setAttribute("data-for", "row" + h);
                    o.appendChild(f);
                    g.appendChild(o)
                }
            o = document.createElement("tr");
            u = document.createElement("th");
            u.className = "pvtTotalLabel pvtColTotalLabel";
            u.innerHTML = i.localeStrings.totals;
            u.setAttribute("colspan", c.length + (0 === l.length ? 0 : 1));
            o.appendChild(u);
            for (e in a) n.call(a, e) && (p = a[e], y = t.getAggregator([], p), s = y.value(), f = document.createElement("td"), f.className = "pvtTotal colTotal", f.textContent = y.format(s), f.setAttribute("data-value", s), null != v && (f.onclick = v(s, [], p)), f.setAttribute("data-for", "col" + e), o.appendChild(f));
            return y = t.getAggregator([], []), s = y.value(), f = document.createElement("td"), f.className = "pvtGrandTotal", f.textContent = y.format(s), f.setAttribute("data-value", s), null != v && (f.onclick = v(s, [], [])), o.appendChild(f), g.appendChild(o), b.appendChild(g), b.setAttribute("data-numrows", k.length), b.setAttribute("data-numcols", a.length), b
        }, r.fn.pivot = function(n, t, i) {
            var a, s, y, l, u, p, e, h;
            null == i && (i = "en");
            null == o[i] && (i = "en");
            a = {
                cols: [],
                rows: [],
                vals: [],
                rowOrder: "key_a_to_z",
                colOrder: "key_a_to_z",
                dataClass: v,
                filter: function() {
                    return !0
                },
                aggregator: f.count()(),
                aggregatorName: "Count",
                sorters: {},
                derivedAttributes: {},
                renderer: c
            };
            l = r.extend(!0, {}, o.en.localeStrings, o[i].localeStrings);
            y = {
                rendererOptions: {
                    localeStrings: l
                },
                localeStrings: l
            };
            u = r.extend(!0, {}, y, r.extend({}, a, t));
            e = null;
            try {
                p = new u.dataClass(n, u);
                try {
                    e = u.renderer(p, u.rendererOptions)
                } catch (w) {
                    s = w;
                    "undefined" != typeof console && null !== console && console.error(s.stack);
                    e = r("<span>").html(u.localeStrings.renderError)
                }
            } catch (w) {
                s = w;
                "undefined" != typeof console && null !== console && console.error(s.stack);
                e = r("<span>").html(u.localeStrings.computeError)
            }
            for (h = this[0]; h.hasChildNodes();) h.removeChild(h.lastChild);
            return this.append(e)
        }, r.fn.pivotUI = function(i, u, f, e) {
            var nt, w, tt, at, l, g, vt, ei, oi, yt, si, b, pt, ut, hi, ci, li, ai, wt, bt, ft, et, h, k, ot, st, kt, dt, gt, ni, a, vi, ht, ct, ti, it, ii, p, ri, ui, d, rt, fi, lt, c;
            null == f && (f = !1);
            null == e && (e = "en");
            null == o[e] && (e = "en");
            ei = {
                derivedAttributes: {},
                aggregators: o[e].aggregators,
                renderers: o[e].renderers,
                hiddenAttributes: [],
                hiddenFromAggregators: [],
                hiddenFromDragDrop: [],
                menuLimit: 500,
                cols: [],
                rows: [],
                vals: [],
                rowOrder: "key_a_to_z",
                colOrder: "key_a_to_z",
                dataClass: v,
                exclusions: {},
                inclusions: {},
                unusedAttrsVertical: 85,
                autoSortUnusedAttrs: !1,
                onRefresh: null,
                filter: function() {
                    return !0
                },
                sorters: {}
            };
            wt = r.extend(!0, {}, o.en.localeStrings, o[e].localeStrings);
            ai = {
                rendererOptions: {
                    localeStrings: wt
                },
                localeStrings: wt
            };
            yt = this.data("pivotUIOptions");
            h = null == yt || f ? r.extend(!0, {}, ai, r.extend({}, ei, u)) : yt;
            try {
                l = {};
                bt = [];
                st = 0;
                v.forEachRecord(i, h.derivedAttributes, function(t) {
                    var i, u, f, r;
                    if (h.filter(t)) {
                        bt.push(t);
                        for (i in t) n.call(t, i) && null == l[i] && (l[i] = {}, st > 0 && (l[i]["null"] = st));
                        for (i in l) r = null != (f = t[i]) ? f : "null", null == (u = l[i])[r] && (u[r] = 0), l[i][r]++;
                        return st++
                    }
                });
                d = r("<table>", {
                    "class": "pvtUi"
                }).attr("cellpadding", 5);
                ct = r("<td>");
                ht = r("<select>").addClass("pvtRenderer").appendTo(ct).bind("change", function() {
                    return a()
                });
                kt = h.renderers;
                for (c in kt) n.call(kt, c) && r("<option>").val(c).html(c).appendTo(ht);
                if (rt = r("<td>").addClass("pvtAxisContainer pvtUnused"), it = function() {
                        var n = [];
                        for (nt in l) t.call(h.hiddenAttributes, nt) < 0 && n.push(nt);
                        return n
                    }(), ii = function() {
                        var n, r, i;
                        for (i = [], n = 0, r = it.length; r > n; n++) g = it[n], t.call(h.hiddenFromAggregators, g) < 0 && i.push(g);
                        return i
                    }(), p = function() {
                        var n, r, i;
                        for (i = [], n = 0, r = it.length; r > n; n++) g = it[n], t.call(h.hiddenFromDragDrop, g) < 0 && i.push(g);
                        return i
                    }(), lt = !1, fi = "auto" === h.unusedAttrsVertical ? 120 : parseInt(h.unusedAttrsVertical), !isNaN(fi)) {
                    for (at = 0, ut = 0, hi = p.length; hi > ut; ut++) nt = p[ut], at += nt.length;
                    lt = at > fi
                }
                rt.addClass(h.unusedAttrsVertical === !0 || lt ? "pvtVertList" : "pvtHorizList");
                si = function(n) {
                    var e, g, w, o, s, c, k, v, nt, p, tt, d, it, ut, ft, u, et, i, f;
                    if (f = function() {
                            var t = [];
                            for (ft in l[n]) t.push(ft);
                            return t
                        }(), v = !1, i = r("<div>").addClass("pvtFilterBox").hide(), i.append(r("<h4>").append(r("<span>").text(n), r("<span>").addClass("count").text("(" + f.length + ")"))), f.length > h.menuLimit) i.append(r("<p>").html(h.localeStrings.tooMany));
                    else
                        for (f.length > 5 && (o = r("<p>").appendTo(i), it = y(h.sorters, n), tt = h.localeStrings.filterResults, r("<input>", {
                                type: "text"
                            }).appendTo(o).attr({
                                placeholder: tt,
                                "class": "pvtSearch"
                            }).bind("keyup", function() {
                                var f, u, n;
                                return n = r(this).val().toLowerCase().trim(), u = function(i, r) {
                                    return function(u) {
                                        var f, e;
                                        return f = n.substring(i.length).trim(), 0 === f.length ? !0 : (e = Math.sign(it(u.toLowerCase(), f)), t.call(r, e) >= 0)
                                    }
                                }, f = n.startsWith(">=") ? u(">=", [1, 0]) : n.startsWith("<=") ? u("<=", [-1, 0]) : n.startsWith(">") ? u(">", [1]) : n.startsWith("<") ? u("<", [-1]) : n.startsWith("~") ? function(t) {
                                    return 0 === n.substring(1).trim().length ? !0 : t.toLowerCase().match(n.substring(1))
                                } : function(t) {
                                    return -1 !== t.toLowerCase().indexOf(n)
                                }, i.find(".pvtCheckContainer p label span.value").each(function() {
                                    return f(r(this).text()) ? r(this).parent().parent().show() : r(this).parent().parent().hide()
                                })
                            }), o.append(r("<br>")), r("<button>", {
                                type: "button"
                            }).appendTo(o).html(h.localeStrings.selectAll).bind("click", function() {
                                return i.find("input:visible:not(:checked)").prop("checked", !0).toggleClass("changed"), !1
                            }), r("<button>", {
                                type: "button"
                            }).appendTo(o).html(h.localeStrings.selectNone).bind("click", function() {
                                return i.find("input:visible:checked").prop("checked", !1).toggleClass("changed"), !1
                            })), g = r("<div>").addClass("pvtCheckContainer").appendTo(i), d = f.sort(y(h.sorters, n)), p = 0, nt = d.length; nt > p; p++) u = d[p], et = l[n][u], s = r("<label>"), c = !1, h.inclusions[n] ? c = t.call(h.inclusions[n], u) < 0 : h.exclusions[n] && (c = t.call(h.exclusions[n], u) >= 0), v || (v = c), r("<input>").attr("type", "checkbox").addClass("pvtFilter").attr("checked", !c).data("filter", [n, u]).appendTo(s).bind("change", function() {
                            return r(this).toggleClass("changed")
                        }), s.append(r("<span>").addClass("value").text(u)), s.append(r("<span>").addClass("count").text("(" + et + ")")), g.append(r("<p>").append(s));
                    return w = function() {
                        return i.find("[type='checkbox']").length > i.find("[type='checkbox']:checked").length ? e.addClass("pvtFilteredAttribute") : e.removeClass("pvtFilteredAttribute"), i.find(".pvtSearch").val(""), i.find(".pvtCheckContainer p").show(), i.hide()
                    }, k = r("<p>").appendTo(i), f.length <= h.menuLimit && r("<button>", {
                        type: "button"
                    }).text(h.localeStrings.apply).appendTo(k).bind("click", function() {
                        return i.find(".changed").removeClass("changed").length && a(), w()
                    }), r("<button>", {
                        type: "button"
                    }).text(h.localeStrings.cancel).appendTo(k).bind("click", function() {
                        return i.find(".changed:checked").removeClass("changed").prop("checked", !1), i.find(".changed:not(:checked)").removeClass("changed").prop("checked", !0), w()
                    }), ut = r("<span>").addClass("pvtTriangle").html(" &#x25BE;").bind("click", function(n) {
                        var u, t, f;
                        return t = r(n.currentTarget).position(), u = t.left, f = t.top, i.css({
                            left: u + 10,
                            top: f + 10
                        }).show()
                    }), e = r("<li>").addClass("axis_" + b).append(r("<span>").addClass("pvtAttr").text(n).data("attrName", n).append(ut)), v && e.addClass("pvtFilteredAttribute"), rt.append(e).append(i)
                };
                for (b in p) n.call(p, b) && (tt = p[b], si(tt));
                ri = r("<tr>").appendTo(d);
                w = r("<select>").addClass("pvtAggregator").bind("change", function() {
                    return a()
                });
                dt = h.aggregators;
                for (c in dt) n.call(dt, c) && w.append(r("<option>").val(c).html(c));
                for (k = {
                        key_a_to_z: {
                            rowSymbol: "&varr;",
                            colSymbol: "&harr;",
                            next: "value_a_to_z"
                        },
                        value_a_to_z: {
                            rowSymbol: "&darr;",
                            colSymbol: "&rarr;",
                            next: "value_z_to_a"
                        },
                        value_z_to_a: {
                            rowSymbol: "&uarr;",
                            colSymbol: "&larr;",
                            next: "key_a_to_z"
                        }
                    }, ti = r("<a>", {
                        role: "button"
                    }).addClass("pvtRowOrder").data("order", h.rowOrder).html(k[h.rowOrder].rowSymbol).bind("click", function() {
                        return r(this).data("order", k[r(this).data("order")].next), r(this).html(k[r(this).data("order")].rowSymbol), a()
                    }), vt = r("<a>", {
                        role: "button"
                    }).addClass("pvtColOrder").data("order", h.colOrder).html(k[h.colOrder].colSymbol).bind("click", function() {
                        return r(this).data("order", k[r(this).data("order")].next), r(this).html(k[r(this).data("order")].colSymbol), a()
                    }), r("<td>").addClass("pvtVals").appendTo(ri).append(w).append(ti).append(vt).append(r("<br>")), r("<td>").addClass("pvtAxisContainer pvtHorizList pvtCols").appendTo(ri), ui = r("<tr>").appendTo(d), ui.append(r("<td>").addClass("pvtAxisContainer pvtRows").attr("valign", "top")), ot = r("<td>").attr("valign", "top").addClass("pvtRendererArea").appendTo(ui), h.unusedAttrsVertical === !0 || lt ? (d.find("tr:nth-child(1)").prepend(ct), d.find("tr:nth-child(2)").prepend(rt)) : d.prepend(r("<tr>").append(ct).append(rt)), this.html(d), gt = h.cols, ft = 0, ci = gt.length; ci > ft; ft++) c = gt[ft], this.find(".pvtCols").append(this.find(".axis_" + r.inArray(c, p)));
                for (ni = h.rows, et = 0, li = ni.length; li > et; et++) c = ni[et], this.find(".pvtRows").append(this.find(".axis_" + r.inArray(c, p)));
                null != h.aggregatorName && this.find(".pvtAggregator").val(h.aggregatorName);
                null != h.rendererName && this.find(".pvtRenderer").val(h.rendererName);
                pt = !0;
                vi = function(n) {
                    return function() {
                        var u, e, g, p, o, k, nt, it, l, i, v, y, d, f;
                        if (i = {
                                derivedAttributes: h.derivedAttributes,
                                localeStrings: h.localeStrings,
                                rendererOptions: h.rendererOptions,
                                sorters: h.sorters,
                                cols: [],
                                rows: [],
                                dataClass: h.dataClass
                            }, o = null != (it = h.aggregators[w.val()]([])().numInputs) ? it : 0, f = [], n.find(".pvtRows li span.pvtAttr").each(function() {
                                return i.rows.push(r(this).data("attrName"))
                            }), n.find(".pvtCols li span.pvtAttr").each(function() {
                                return i.cols.push(r(this).data("attrName"))
                            }), n.find(".pvtVals select.pvtAttrDropdown").each(function() {
                                return 0 === o ? r(this).remove() : (o--, "" !== r(this).val() ? f.push(r(this).val()) : void 0)
                            }), 0 !== o)
                            for (nt = n.find(".pvtVals"), c = v = 0, l = o; l >= 0 ? l > v : v > l; c = l >= 0 ? ++v : --v) {
                                for (p = r("<select>").addClass("pvtAttrDropdown").append(r("<option>")).bind("change", function() {
                                        return a()
                                    }), y = 0, g = ii.length; g > y; y++) tt = ii[y], p.append(r("<option>").val(tt).text(tt));
                                nt.append(p)
                            }
                        return pt && (f = h.vals, b = 0, n.find(".pvtVals select.pvtAttrDropdown").each(function() {
                            return r(this).val(f[b]), b++
                        }), pt = !1), i.aggregatorName = w.val(), i.vals = f, i.aggregator = h.aggregators[w.val()](f), i.renderer = h.renderers[ht.val()], i.rowOrder = ti.data("order"), i.colOrder = vt.data("order"), u = {}, n.find("input.pvtFilter").not(":checked").each(function() {
                            var n;
                            return n = r(this).data("filter"), null != u[n[0]] ? u[n[0]].push(n[1]) : u[n[0]] = [n[1]]
                        }), e = {}, n.find("input.pvtFilter:checked").each(function() {
                            var n;
                            return n = r(this).data("filter"), null != u[n[0]] ? null != e[n[0]] ? e[n[0]].push(n[1]) : e[n[0]] = [n[1]] : void 0
                        }), i.filter = function(n) {
                            var r, i, f, e;
                            if (!h.filter(n)) return !1;
                            for (i in u)
                                if (r = u[i], f = "" + (null != (e = n[i]) ? e : "null"), t.call(r, f) >= 0) return !1;
                            return !0
                        }, ot.pivot(bt, i), k = r.extend({}, h, {
                            cols: i.cols,
                            rows: i.rows,
                            colOrder: i.colOrder,
                            rowOrder: i.rowOrder,
                            vals: f,
                            exclusions: u,
                            inclusions: e,
                            inclusionsInfo: e,
                            aggregatorName: w.val(),
                            rendererName: ht.val()
                        }), n.data("pivotUIOptions", k), h.autoSortUnusedAttrs && (d = n.find("td.pvtUnused.pvtAxisContainer"), r(d).children("li").sort(function(n, t) {
                            return s(r(n).text(), r(t).text())
                        }).appendTo(d)), ot.css("opacity", 1), null != h.onRefresh ? h.onRefresh(k) : void 0
                    }
                }(this);
                a = function() {
                    return function() {
                        return ot.css("opacity", .5), setTimeout(vi, 10)
                    }
                }(this);
                a();
                this.find(".pvtAxisContainer").sortable({
                    update: function(n, t) {
                        if (null == t.sender) return a()
                    },
                    connectWith: this.find(".pvtAxisContainer"),
                    items: "li",
                    placeholder: "pvtPlaceholder"
                })
            } catch (yi) {
                oi = yi;
                "undefined" != typeof console && null !== console && console.error(oi.stack);
                this.html(h.localeStrings.uiRenderError)
            }
            return this
        }, r.fn.heatmap = function(n, t) {
            var s, i, h, c, u, f, l, a, v, e, o;
            switch (null == n && (n = "heatmap"), a = this.data("numrows"), l = this.data("numcols"), s = null != t && null != (v = t.heatmap) ? v.colorScaleGenerator : void 0, null == s && (s = function(n) {
                var i, t;
                return t = Math.min.apply(Math, n), i = Math.max.apply(Math, n),
                    function(n) {
                        var r;
                        return r = 255 - Math.round(255 * (n - t) / (i - t)), "rgb(255," + r + "," + r + ")"
                    }
            }), i = function(n) {
                return function(t) {
                    var f, i, u;
                    return i = function(i) {
                        return n.find(t).each(function() {
                            var n;
                            return n = r(this).data("value"), null != n && isFinite(n) ? i(n, r(this)) : void 0
                        })
                    }, u = [], i(function(n) {
                        return u.push(n)
                    }), f = s(u), i(function(n, t) {
                        return t.css("background-color", f(n))
                    })
                }
            }(this), n) {
                case "heatmap":
                    i(".pvtVal");
                    break;
                case "rowheatmap":
                    for (h = u = 0, e = a; e >= 0 ? e > u : u > e; h = e >= 0 ? ++u : --u) i(".pvtVal.row" + h);
                    break;
                case "colheatmap":
                    for (c = f = 0, o = l; o >= 0 ? o > f : f > o; c = o >= 0 ? ++f : --f) i(".pvtVal.col" + c)
            }
            return i(".pvtTotal.rowTotal"), i(".pvtTotal.colTotal"), this
        }, r.fn.barchart = function() {
            var i, u, n, e, f, t;
            for (f = this.data("numrows"), e = this.data("numcols"), i = function(n) {
                    return function(t) {
                        var o, i, u, s, f, e;
                        return o = function(i) {
                            return n.find(t).each(function() {
                                var n;
                                return n = r(this).data("value"), null != n && isFinite(n) ? i(n, r(this)) : void 0
                            })
                        }, e = [], o(function(n) {
                            return e.push(n)
                        }), i = Math.max.apply(Math, e), 0 > i && (i = 0), s = i, u = Math.min.apply(Math, e), 0 > u && (s = i - u), f = function(n) {
                            return 100 * n / (1.4 * s)
                        }, o(function(n, t) {
                            var i, o, s, e;
                            return s = t.text(), e = r("<div>").css({
                                position: "relative",
                                height: "55px"
                            }), o = "gray", i = 0, 0 > u && (i = f(-u)), 0 > n && (i += f(n), o = "darkred", n = -n), e.append(r("<div>").css({
                                position: "absolute",
                                bottom: i + "%",
                                left: 0,
                                right: 0,
                                height: f(n) + "%",
                                "background-color": o
                            })), e.append(r("<div>").text(s).css({
                                position: "relative",
                                "padding-left": "5px",
                                "padding-right": "5px"
                            })), t.css({
                                padding: 0,
                                "padding-top": "5px",
                                "text-align": "center"
                            }).html(e)
                        })
                    }
                }(this), u = n = 0, t = f; t >= 0 ? t > n : n > t; u = t >= 0 ? ++n : --n) i(".pvtVal.row" + u);
            return i(".pvtTotal.colTotal"), this
        }
    })
}).call(this),
    function() {
        var n;
        (n = function(n) {
            return "object" == typeof exports && "object" == typeof module ? n(require("jquery")) : "function" == typeof define && define.amd ? define(["jquery"], n) : n(jQuery)
        })(function(n) {
            var r, h, i, o, u, f, s, e, t;
            return s = n.pivotUtilities.numberFormat, t = n.pivotUtilities.aggregatorTemplates, e = n.pivotUtilities.renderers, f = n.pivotUtilities.gchart_renderers, h = n.pivotUtilities.d3_renderers, r = n.pivotUtilities.c3_renderers, i = s({
                thousandsSep: ",",
                decimalSep: "."
            }), o = s({
                digitsAfterDecimal: 0,
                thousandsSep: ",",
                decimalSep: "."
            }), u = s({
                digitsAfterDecimal: 2,
                scaler: 100,
                suffix: "%",
                thousandsSep: ",",
                decimalSep: "."
            }), n.pivotUtilities.locales.zh = {
                localeStrings: {
                    renderError: "展示结果时出错。",
                    computeError: "计算结果时出错。",
                    uiRenderError: "展示界面时出错。",
                    selectAll: "选择全部",
                    selectNone: "全部不选",
                    tooMany: "(因数据过多而无法列出)",
                    filterResults: "输入值帮助筛选",
                    totals: "合计",
                    vs: "于",
                    by: "分组于"
                },
                aggregators: {
                    "频数": t.count(o),
                    "非重复值的个数": t.countUnique(o),
                    "列出非重复值": t.listUnique(", "),
                    "求和": t.sum(i),
                    "求和后取整": t.sum(o),
                    "平均值": t.average(i),
                    "最小值": t.min(i),
                    "最大值": t.max(i),
                    "两和之比": t.sumOverSum(i),
                    "二项分布：置信度为80%时的区间上限": t.sumOverSumBound80(!0, i),
                    "二项分布：置信度为80%时的区间下限": t.sumOverSumBound80(!1, i),
                    "和在总计中的比例": t.fractionOf(t.sum(), "total", u),
                    "和在行合计中的比例": t.fractionOf(t.sum(), "row", u),
                    "和在列合计中的比例": t.fractionOf(t.sum(), "col", u),
                    "频数在总计中的比例": t.fractionOf(t.count(), "total", u),
                    "频数在行合计中的比例": t.fractionOf(t.count(), "row", u),
                    "频数在列合计中的比例": t.fractionOf(t.count(), "col", u)
                },
                renderers: {
                    "表格": e.Table,
                    "表格内柱状图": e["Table Barchart"],
                    "热图": e.Heatmap,
                    "行热图": e["Row Heatmap"],
                    "列热图": e["Col Heatmap"]
                }
            }, f && (n.pivotUtilities.locales.zh.gchart_renderers = {
                "折线图(g)": f["Line Chart"],
                "柱形图(g)": f["Bar Chart"],
                "堆栈柱形图(g)": f["Stacked Bar Chart"],
                "面积图(g)": f["Area Chart"]
            }, n.pivotUtilities.locales.zh.renderers = n.extend(n.pivotUtilities.locales.zh.renderers, n.pivotUtilities.locales.zh.gchart_renderers)), h && (n.pivotUtilities.locales.zh.d3_renderers = {
                "树图": h.Treemap
            }, n.pivotUtilities.locales.zh.renderers = n.extend(n.pivotUtilities.locales.zh.renderers, n.pivotUtilities.locales.zh.d3_renderers)), r && (n.pivotUtilities.locales.zh.c3_renderers = {
                "折线图": r["Line Chart"],
                "柱形图": r["Bar Chart"],
                "堆栈柱形图": r["Stacked Bar Chart"],
                "面积图": r["Area Chart"],
                "散点图": r["Scatter Chart"]
            }, n.pivotUtilities.locales.zh.renderers = n.extend(n.pivotUtilities.locales.zh.renderers, n.pivotUtilities.locales.zh.c3_renderers)), n.pivotUtilities.locales.zh
        })
    }.call(this)